<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2021/4/12
 * Time: 18:39
 */
use \Event as Event;
use \EventBase as EventBase;

class e
{
    public $eventBase ;
    public $client ;
    public $count = [];

    public function __construct($eventBase, $client)
    {
        $this->eventBase = $eventBase;
        $this->client = $client;
    }

    public function handler()
    {
        $event = new Event($this->eventBase, $this->client, Event::PERSIST | Event::READ | Event::WRITE, function($socket){
            var_dump(fread($socket, 65535));
            fwrite($socket, 'e handler');

            // 处理后移除
            ($this->count[(int)$socket][ Event::PERSIST | Event::READ | Event::WRITE ])->free();
        });

        $event->add();
        $this->count[(int)$this->client][ Event::PERSIST | Event::READ | Event::WRITE ] = $event;

        var_dump($this->count);
    }
}